<template>
  <van-cell-group>
    <van-cell center>
      <span slot="title" style="color: #b0b0b0; font-size: 12px">当前定位</span>
      <span
        slot="default"
        style="color: skyblue; font-size: 14px"
        @click="getCurrentCity(true)"
        >重新定位</span
      >
      <span
        slot="label"
        style="color: #000; font-size: 14px"
        @click="clickBtn"
        >{{ currentCity.name }}</span
      >
    </van-cell>
  </van-cell-group>
</template>

<script>
export default {
  name: 'currentCity',
  data() {
    return {
      currentCity: JSON.parse(localStorage.getItem('currentCity')),
      loading: false,
    }
  },
  created() {},
  methods: {
    clickBtn() {
      this.$store.commit('setcurrentAddress', this.currentCity)
      this.$router.push('/home')
    },
    async getCurrentCity(flag) {
      if (flag) {
        this.$toast.loading({
          message: '保存中...',
          forbidClick: true, // 禁止背景点击
          duration: 0, // 持续展示
        })
      }
      if (flag) {
        this.$toast.success('更新成功')
      }
    },
  },
}
</script>

<style>
</style>